<?php

namespace App\Models\Setting\Repository;

use App\Models\Setting\Model\UnitType;
use Illuminate\Database\Eloquent\Model;

class UnitTypeRepository extends Model{

    protected $unitType;

    public function __construct()
    {
        $this->unitType = new UnitType();
    }


    public function statusArray()
    {
        return [
            UnitType::UP=>'启用',
            UnitType::DOWN=>'关闭'
        ];
    }

    public function settingTypeArray()
    {
        $unitType = UnitType::where([
            'status'=>UnitType::UP
        ])->get();
        if($unitType->toArray())
        {
            return $unitType->pluck('text','id')->toArray();
        }else{
            return [];
        }
    }

    public function getStatusText($status)
    {
        switch ($status){
            case UnitType::UP:
                return '启用';
            case UnitType::DOWN:
                return '关闭';
            default:
                return "";
        }
    }


}

